<template>
  <div>
    <h3>{{title}}</h3>
    <div class="container">
      <vxe-table
        border
        ref="xTable"
        :data="table.tableData">
        <vxe-column
          v-for="config,index in table.tableColumn"
          :key="index"
          :type="config.type"
          :field="config.field"
          :title="config.title"
          :fixed="config.fixed"
          :width="config.width"
          :filters="config.filters">
          <template #default="{ row,column }">
            <div v-if="column.property=='metaId'">{{dict_meta[row[column.property]]}}</div>
            <el-input v-else @change="inputChange(row,column)" @input="inputInput(row,column)" v-model="row[column.property]=='-1'?'':row[column.property]"
            :disabled="row[column.property]=='-1'||row.disabledVal"></el-input>
          </template>
        </vxe-column>
      </vxe-table>
    </div>
  </div>
</template>

<script>
  export default {
    props: ['title','table','dict_meta'],
    methods: {
      inputChange(row,column){
        row['valid'] = true
      },
      inputInput(row,column){
        let columnArr = this.table.tableColumn
        let tableData = this.table.tableData
        if(this.title == '动作质量七项必填'){
          return
        }
        if(row[column.property] == -1){
          row[column.property] = '- 1'
        }
        if(row[column.property]!=''){
          this.table.tableData.forEach(item=>{
            if(item.metaId!=row.metaId){
              item.disabledVal = true
              // 如果是其他的禁用立定跳远
              if(this.title == '下肢爆发力二选一'){
                if(item.metaId==26){
                  item.disabledVal = true
                }else{
                  item.disabledVal = false
                }
              }
            }
          })
          // 如果是立定跳远禁用其他
          if(this.title == '下肢爆发力二选一'){
            if(row.metaId == 26){
              this.table.tableData.forEach(item=>{
                if(item.metaId!=row.metaId){
                  item.disabledVal = true
                }
              })
            }
          }
        }else{
          let valueBool = false
          let value = ''
          columnArr.forEach(c=>{
            if(c.field != 'metaId'){
              tableData.forEach((r,i)=>{
                if(r[c.field]!= '-1'){
                  value += r[c.field]
                }else{
                  valueBool = false
                }
              })
            }
          })
          // 清空禁用
          tableData.forEach((r,i)=>{
            if(r.metaId!=row.metaId && !value){
              r.disabledVal = false
            }
          })
        }
      }
    },
  }
</script>

<style scoped>

</style>
